﻿/*                       NOTICE
 * 
 * This software was produced for the U. S. Government
 * under Contract No. FA8721-10-C-0001, and is
 * subject to the Rights in Noncommercial Computer Software
 * and Noncommercial Computer Software Documentation Clause
 * (DFARS) 252.227-7014 (JUN 1995)
 * 
 * Approved for Public Release: 11-2435
 * © 2011 The MITRE Corporation. All Rights Reserved. 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace MXSE.MultiTouch.Gestures
{
    public class DoubleTapGesture : ComplexGesture
    {
        private DateTime startTime;
        private Vector3 firstTapPosition;
        private Vector3 secondTapPosition;

        public static float DOUBLE_TAP_RANGE = 0.008f;
        public static int DOUBLE_TAP_DELAY = 500;

        public DoubleTapGesture(TapGesture tap, TapGesture tap2)
        {
            AddBasic(tap);
            AddBasic(tap2);
            firstTapPosition = tap.startPosition;
            secondTapPosition = tap2.startPosition;

            startTime = DateTime.Now;
        }

        public override void Start()
        {
            contactManager.recognizer.publishMessage(
                "DoubleTap " + Id + " activated at " + secondTapPosition.X + ", " + secondTapPosition.Y + 
                    " - reverting to previous tap position of " + firstTapPosition.X + ", " + firstTapPosition.Y,
                "DoubleTap",
                Id,
                0, 0, 0, 0, firstTapPosition.X, firstTapPosition.Y
            );
        }

        public override void OnDeath()
        { }

        public override void Update()
        { }

        public override bool Destroyed()
        {
            return Basics[0].Destroyed() && Basics[1].Destroyed();
        }
    }
}
